<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* .nav a {
            color: #333;
            text-decoration: none;
        } */
        .nav .router-link-exact-active {
            color: blue;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="nav">
            <!-- 
                exact-active-class 当路由被精确匹配到的时候添加的类名
                他的默认值是 router-link-exact-active

                active-class 当路由被匹配到的时候添加的类名 
                他的默认值是 router-link-active
                将router-link转化为具体的标签的属性 默认是a标签
            -->
            <router-link tag="span" to="/">英雄联盟</router-link>
            <router-link tag="span" to="/pubg">绝地求生</router-link>
            <router-link to="/wzry">王者荣耀</router-link>
            <router-link to="/dnf">dnf</router-link>
        </div>
        
        <router-view></router-view>
    </div>
    <script src="../js/vue.js"></script>
    <script src="../js/vue-router.js"></script>
    <script>
        const page1 = {
            // path是路由跳转的地址
            // query是一种携带参数的方法 参数标签形式为在地址栏显示 key=value&key=value的形式
            template: `<div>
                这是英雄联盟
                <router-link :to="{
                    name: 'detail',
                    query: {
                        id: 1234,
                        name: '张三'
                    }
                }">进入详情页</router-link>
                </div>`
        }
        const page2 = {
            template: `<div>这是王者荣耀</div>`
        }
        const page3 = {
            template: `<div>这是绝地求生</div>`
        }
        const page4 = {
            template: `<div>这是dnf</div>`
        }
        const detail = {
            template: `<div>这是详情页</div>`,
            created() {
                // $route当前路由的路由对象
                // 通过this.$route.query可以获取query参数
                console.log(this.$route.query);
            }
        }
        const router = new VueRouter({
            routes: [
                {
                    path: '/',
                    name: 'Lol',
                    component: page1
                },
                {
                    path: '/pubg',
                    name: 'pubg',
                    component: page3
                },
                {
                    path: '/wzry',
                    name: 'wzry',
                    component: page2
                },
                {
                    path: '/dnf',
                    name: 'dnf',
                    component: page4
                },{
                    path: '/detail',
                    name: 'detail',
                    component: detail
                }
            ]
        })


        new Vue({
            router
        }).$mount('#app')
    </script>
</body>
</html>